import React, {Component} from 'react';
export default class NameForm extends Component {
    constructor(props) {
        super(props);
        this.state = {value: '',selvalue:''};
        this.handleChange = this.handleChange.bind(this);
        this.handleSubmit = this.handleSubmit.bind(this);
        this.selHandleChange = this.selHandleChange.bind(this);
    }

    handleChange(event) {
        this.setState({
            value: event.target.value
        });
    }

    selHandleChange(event) {
        this.setState({
            selvalue: event.target.value
        })
    }



    handleSubmit(event){
        alert('A name was submitted: ' + this.state.value + " , selected value:"+this.state.selvalue);
        event.preventDefault();
    }

    render() {
        return (
            <form onSubmit={this.handleSubmit}>
                <label>
                    Name:
                    <textarea type="text" value={this.state.value} onChange={this.handleChange}/>
                </label>
                <br/>
                <label>
                    Pick your favorite La croix flavor:
                    <select value={this.state.selvalue} onChange={this.selHandleChange}>
                        <option value="Apple">Apple</option>
                        <option value="Orange">Orange</option>
                        <option value="Banana">Banana</option>
                    </select>
                </label>
                <input type="submit" value="Submit"/>
            </form>
        )
    }
}